package com.one.blocks.eds.core;

/**
 * @author <a href="mailto:idler41@163.con">linfuxin</a> created on 2023-09-11 10:03:19
 */
public class LocalEdsRoutingKeyHolder {
    /**
     * 动态数据源名称上下文
     */
    private static final ThreadLocal<String> LOCAL_DS_KEY = new ThreadLocal<>();

    /**
     * 设置/切换数据源
     */
    public static void setKey(String key) {
        LOCAL_DS_KEY.set(key);
    }

    /**
     * 获取数据源名称
     */
    public static String getKey() {
        return LOCAL_DS_KEY.get();
    }

    /**
     * 删除当前数据源名称
     */
    public static void clear() {
        LOCAL_DS_KEY.remove();
    }
}
